package com.woniuxy.shirospring.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author linke
 * @version 1.0
 * @className: WebMvcConfiguration
 * @description: 配置视图映射
 * @date 2021/11/20 10:19
 */
@Configuration
public class WebMvcConfiguration {
    /**
     * 配置视图映射页面
     * 需要配置 不然访问页面找不到
     * @return WebMvcConfigurer 视图映射规则
     */
    @Bean
    public WebMvcConfigurer webMvcConfigurer(){
        return new WebMvcConfigurer() {
            @Override
            public void addViewControllers(ViewControllerRegistry registry) {
                registry.addViewController("/index.html").setViewName("/index");
                registry.addViewController("/login.html").setViewName("/login");
                registry.addViewController("/unauthorizedUrl.html").setViewName("/unauthorized");
            }
        };
    }
}
